<div class="row">
    {% include 'rebs/partials/project_select.html' %}

    <div class="col-sm-12 col-md-4">
        <div class="form-group row mb-3">
            <label for="id_type"
                   class="col-4 col-form-label text-center bg-info-lighten">타입</label>
            <div class="col-8">
                <select name="type" id="id_type"
                        class="form-control  select2 {% if request.GET.payment_id and not request.GET.contract %}bg-warning-lighten{% endif %}"
                        onchange="type_select(this.form)">
                    <option value="">---------</option>
                    {% for type in types %}
                        <option value="{{ type.id }}">{{ type }}</option>
                    {% endfor %}
                </select>
            </div>
        </div>
    </div>

    <div class="col-12 col-md-4">
        <div class="form-group row mb-3">
            <label for="id_contract"
                   class="col-4 col-form-label text-center bg-info-lighten">{{ this_type.id }}계약자</label>
            <div class="col-8">
                <select name="contract" id="id_contract"
                        class="form-control  select2 {% if request.GET.payment_id and not request.GET.contract %}bg-warning-lighten{% endif %}"
                        {% if not request.GET.type and not request.GET.contract %}disabled{% endif %}
                        onchange="submit()">
                    <option value="">---------</option>
                    {% for contract in contracts %}
                        <option value="{{ contract.id }}"
                                {% if contract.id == request.GET.contract %}selected{% endif %}>
                            {{ contract.contractor }}
                        </option>
                    {% endfor %}
                </select>
            </div>
        </div>
    </div>

    <div class="mb-2 col-12"></div>

    <div class="col-12 col-md-8 my-auto">
        {% if q_contracts %}
            {% for qc in q_contracts %}
                <a href="?project={{ this_project.id }}&type={{ qc.contractunit.unit_type.id }}&contract={{ qc.id }}&payment_id={{ request.GET.payment_id }}&q={{ request.GET.q }}"
                   class="{% if not qc.activation %}text-danger{% endif %}">
                    {{ qc.contractor }}
                </a>
                &nbsp;&nbsp;&nbsp;
            {% endfor %}
            <a href="?project=
                    {{ this_project.id }}{% for key, value in request.GET.items %}{% if key != 'project' and key != 'q' %}&{{ key }}={{ value }}{% endif %}{% endfor %}">
                <i class="mdi mdi-window-close text-black-50 mdi-18px"></i>
            </a>
        {% else %}
            {% if request.GET.q %}
                <span class="text-danger pl-3">"<u
                        class="text-primary">{{ request.GET.q }}</u>" 검색어로 등록된 데이터가 없습니다.</span>
            {% endif %}
        {% endif %}
    </div>

    <div class="col-sm-12 col-md-4">
        <div class="input-group">
            <input type="hidden" name="payment_id" value="{{ request.GET.payment_id }}">
            <input name="q" id="id_q" type="text"
                   class="form-control {% if request.GET.payment_id and not request.GET.contract %}bg-warning-lighten{% endif %}"
                   placeholder="검색어 - 계약자 / 입금자 / 계약코드" aria-label="검색어"
                   onclick="this.value=''">
            <div class="input-group-append">
                <button class="btn btn-info" type="button" onclick="submit()">검색</button>
            </div>
        </div>
    </div>
</div>
